<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        body {
            height: 2000px;
        }

        img {
            position: fixed;
        }

        .box {
            width: 200px;
            height: 200px;
            background-color: #ff3040;
            position: fixed;
            top: 200px;
            left: 200px;
        }
    </style>
</head>
<body>
<div class="box"></div>
<img src="images/cursor.gif" alt="" id="pic"/>

<script>
    var pic = document.getElementById("pic");
    document.onmousemove = function (e) {
        e = e || window.event;
        pic.style.left = e.clientX - 75 + "px";//记得加单位
        pic.style.top = e.clientY - 87 + "px";

        //pic.style.left = e.pageX + "px";//记得加单位
        //pic.style.top = e.pageY + "px";
    }
</script>
</body>
</html>